package com.example.vue_shop.components.shopparams.service.impl;

import com.example.vue_shop.components.shopparams.entity.ShopParams;
import com.example.vue_shop.components.shopparams.mapper.ShopParamsMapper;
import com.example.vue_shop.components.shopparams.service.ShopParamsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lipengwei
 */
@Service
public class ShopParamsServiceImpl implements ShopParamsService {

    @Resource(name = "shopParamsMapper")
    private ShopParamsMapper shopParamsMapper;

    @Override
    public Map<String, Object> getShopParamsList(int id, String type) {
        List<ShopParams> shopParamsList = shopParamsMapper
                .getShopParamsListByShopTypeIdAndShopParamsType(id, type);
        Map<String, Object> result = new HashMap<>(1);
        result.put("shopParamsList", shopParamsList );
        return result;
    }

    @Override
    public void addShopParams(ShopParams shopParams) {
        shopParamsMapper.insert(shopParams);
    }

    @Override
    public void delShopParams(int id) {
        shopParamsMapper.deleteById(id);
    }

    @Override
    public void updateShopParams(ShopParams shopParams) {
        shopParamsMapper.updateById(shopParams);
    }
}
